#!/bin/bash


cat << eof >> ./redis-compose.yml
version: '3.7'
services:
eof

for port in $(seq 1 6);do
cat << EOF >> ./redis-compose.yml
  redis-${port}:
    image: redis:6.0.10-alpine3.13
    container_name: redis-6
    restart: always
    command: redis-server /etc/redis/redis.conf
    ports:
      - 637${port}:6379
      - 1637${port}:16379
    volumes:
      - ./redis/node-${port}/data:/data
      - ./redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf
    networks:
      redis:
        ipv4_address: 172.38.0.1${port}
EOF
done


cat << eof >> ./redis-compose.yml

networks:
  redis:
    driver: bridge
    enable_ipv6: true    
    ipam:
      driver: default
      config:
      - subnet: 172.38.0.0/24
        gateway: 172.38.0.1
eof
